This is the simplest synchronization mechanism. This is a Software Mechanism implemented in User mode. This is a busy waiting solution which can be used for more than two processes. In this mechanism, a Lock variable lockis used. Two values of lock can be possible, either 0 or 1. Lock value 0 means that the critical section is vacant while the lock value 1 means that it is occupied. A process which wants to get into the critical section first checks the value of the lock variable. If it is 0 then it sets the value of lock as 1 and enters into the critical section, otherwise it waits.
Home : In the navbar, the Home button is used to jump to the main page.
Dropdown : Allows you to jump to any algorithm.
Info panel : Displays the value of each required queue and semaphore.
Add Process: Clicking this button adds a new process.
P0 : Clicking this button moves the P0 process forward according to the algorithm.
save PDF : Saves all the statuses of each stage of the algorithm.
Tooltips provide information about the element being hovered over. The elements with tooltips include: Lock Variable, critical section, completed processes, Added, Entry, CS, and Exit.
By clicking the button, the process will move to the Critical Section if it is not occupied or if the Lock is 0.
By clicking "Add Processes," new processes will be added along with a button and process icon.
When the critical section is occupied, processes will move to the suspended queue. For example, if process P0 is occupying the critical section, process P2 will be moved to the suspended queue until the critical section becomes available1.
If a process is already in the critical section and another process tries to interrupt, a warning will be displayed
The message is a gratitude message displayed to indicate that all processes have been completed.
By clicking "Save PDF," a PDF will be generated by collecting all the text from the text area.
The lock variable mechanism doesn't provide Mutual Exclusion in some of the cases. This can be better described by looking at the pseudo code by the Operating System point of view I.E. Assembly code of the program. Let's convert the Code into the assembly language.
Load Lock, R0
CMP R0, #0
JNZ Step 1
Store #1, Lock
Store #0, Lock
The problem with the lock variable mechanism is that, at the same time, more than one process can see the vacant tag and more than one process can enter in the critical section. Hence, the lock variable doesn't provide the mutual exclusion that's why it cannot be used in general.
Since, this method is failed at the basic step; hence, there is no need to talk about the other conditions to be fulfilled.